package jinyilw.swing.graphics;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

public class GraphicsConfig
{

	private final Graphics2D myG;
	private final RenderingHints myHints;

	public GraphicsConfig(Graphics g)
	{
		myG = (Graphics2D) g;
		myHints = (RenderingHints) myG.getRenderingHints().clone();
	}

	public GraphicsConfig setAntialiasing(boolean on)
	{
		myG.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
				on
						? RenderingHints.VALUE_ANTIALIAS_ON
						: RenderingHints.VALUE_ANTIALIAS_OFF);
		return this;
	}

	public Graphics2D getG()
	{
		return myG;
	}

	public void restore()
	{
		myG.setRenderingHints(myHints);
	}
}
